package com.strato.queue.v1_0_0.exec;

import java.util.HashMap;
import java.util.Map;

import com.strato.queue.v1_0_0.api.QueueConsumer;

public class ExecutionManager {

	private static ExecutionManager instance=new ExecutionManager();
	
	private Map<String,ConsumerExecution<?>> executions=new HashMap<String,ConsumerExecution<?>>();
	
	public static ExecutionManager getInstance(){
		return instance;
	}
	
	private ExecutionManager(){
	}
	
	public ConsumerExecution<?> getConsumerExecution(String consumerName){
		return executions.get(consumerName);
	}
	
	public ConsumerExecution<?> getConsumerExecution(Class<? extends QueueConsumer> consumerClass){
		return executions.get(consumerClass.getName());
	}

	public void setConsumerExecution(String consumerName,ConsumerExecution<?> execution){
		executions.put(consumerName, execution);
	}

	public void setConsumerExecution(Class<? extends QueueConsumer> consumerClass,ConsumerExecution<?> execution){
		executions.put(consumerClass.getName(), execution);
	}
	
	public void removeConsumerExecution(String consumerName){
		executions.remove(consumerName);
	}

	public void removeConsumerExecution(Class<? extends QueueConsumer> consumerClass){
		executions.remove(consumerClass.getName());
	}
}
